package com.xiaoxu.content.controller;

import com.xiaoxu.content.model.po.CourseTeacher;
import com.xiaoxu.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author xiaoxu
 * @version 1.0
 * @description 课程教学教师信息接口
 * @date 2023/1/18 16:36
 */
@RestController
@Api(value = "课程教学教师信息编辑接口", tags = "课程教学教师信息编辑接口")
public class CourseTeacherController {
    private final CourseTeacherService courseTeacherService;

    public CourseTeacherController(CourseTeacherService courseTeacherService) {
        this.courseTeacherService = courseTeacherService;
    }

    @ApiOperation("查询教学师资")
    @ApiImplicitParam(value = "courseId",name = "课程Id",required = true,dataType = "Long")
    @GetMapping("/courseTeacher/list/{courseId}")
    public List<CourseTeacher> getCourseTeacherList(@PathVariable Long courseId){
        return courseTeacherService.findCourseTeacherList(courseId);
    }

    @ApiOperation("新增或修改教学师资")
    @PostMapping("/courseTeacher")
    public void addCourseTeacher(@RequestBody @Validated CourseTeacher courseTeacher){
        courseTeacherService.saveOrUpdateCourseTeacher(courseTeacher);
    }

    @ApiOperation("")
    @DeleteMapping("/courseTeacher/course/{courseId}/{teacherId}")
    public void deleteCourseTeacher(@PathVariable Long courseId,@PathVariable Long teacherId){
        courseTeacherService.deleteCourseTeacher(courseId,teacherId);
    }
}
